package com.cc.bill.controller;

import com.cc.bill.service.OssService;
import com.cc.common.utils.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/oss")
public class OssController {

    @Autowired
    private OssService ossService;

    @PostMapping("/upload")
    @ApiOperation("上传其他文件，图片、文件")
    public R upload(MultipartFile file){
        String url = ossService.upload(file);
        return R.ok().put("url",url);
    }

    @PostMapping("/uploadPicByPhoneCamera")
    @ApiOperation("手机拍摄上传图片")
    public R uploadPicByPhoneCamera(MultipartFile file){
        String url = ossService.uploadPicByPhoneCamera(file);
        return R.ok().put("url",url);
    }
}
